import asyncio
import time


async def my_coroutine():
    print("开始执行")
    await asyncio.sleep(1)
    print("执行结束")


async def hello_from_second():
    for i in range(10):
        await asyncio.sleep(1)
        print("你好，我每秒钟负责打印一次")


async def create_task():
    print("开始执行")
    start = time.time()
    task1 = asyncio.create_task(asyncio.sleep(3))
    task2 = asyncio.create_task(asyncio.sleep(3))
    task3 = asyncio.create_task(asyncio.sleep(3))

    await task1
    await task2
    await task3

    task4 = asyncio.create_task(hello_from_second())
    await task4

    end = time.time()
    print("程序运行时间为: %s Seconds" % (end - start))
    print("执行结束")


# 运行create_tast函数
asyncio.run(create_task())
